import java.awt.Point;

public class Tree extends MapObject {

	private int appleCount;
	private static long lastId;

	private int productionTimeRemaining;

	public Tree(Point p) {
		super(p);
		//setId(lastId);
		setAppleCount(0);
		setProductionTimeRemaining(3);
	}

	public void produceApple() {
		setProductionTimeRemaining(getProductionTimeRemaining() - 1);
		if(getProductionTimeRemaining() == 0)
		{
		incrementApple();
		setProductionTimeRemaining(5);
		}
	}

	public void incrementApple() {
		if(getAppleCount()<5)
		{
		setAppleCount(getAppleCount() + 1);
		}
	}

	public void decrementApple() {
		if(getAppleCount()>0)
		{
		setAppleCount(getAppleCount() - 1);
		}
	}

	public MapObjectType getType() {
		return MapObjectType.Tree;
	}

	public int getAppleCount() {
		return appleCount;
	}
	
	private void setAppleCount(int oxygenCount) {
		this.appleCount = oxygenCount;
	}

	private int getProductionTimeRemaining() {
		return productionTimeRemaining;
	}

	private void setProductionTimeRemaining(int productionTimeRemaining) {
		this.productionTimeRemaining = productionTimeRemaining;
	}

	@Override
	public String toString() {
		String s = super.toString();
		return s + ", producing : " + getProductionTimeRemaining();
	}

	public boolean hasApple() {
		return getAppleCount() > 0;
	}
}